#pragma once

#include <vector>
#include <string>

#include <QCoreApplication>
#include <QDir>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QReadWriteLock>

struct BasicDetectionDefine
{
	QString funcNo; // 业务ID  同共享

	int      id;
	QString  uid;       //guid
	QString  barcode;   //条码
	QString  message;   //消息
	QString  date_time;  //记录时间
	int      upload;
};

class BaseSqliteHelper
{
public:
    BaseSqliteHelper();

public:
    virtual void createCheckDB(const QString& tableName);

public:
    QString getTableName();
    virtual bool insertData(QSharedPointer<BasicDetectionDefine> data);
	virtual bool updateData(QSharedPointer<BasicDetectionDefine> data);
	virtual QSharedPointer<BasicDetectionDefine> getNewestData(const QString& barcode);
	static QSharedPointer<BasicDetectionDefine> ConvertTodBasc(const QSqlRecord& record);

private:
    QSqlDatabase getSqliteDatabase(const QString& tableName = "");

private:
    QString m_TableName;

    QReadWriteLock m_rw_lock;
};

